package gkaylee

import (
	"fmt"
	"os"
	"syscall"
	"time"
)

// GetFileLastAccessTime 获取文件的最后访问时间
func GetFileLastAccessTime(fileInfo os.FileInfo) (time.Time, error) {
	stat, ok := fileInfo.Sys().(*syscall.Win32FileAttributeData)
	if !ok {
		return time.Time{}, fmt.Errorf("unsupported file system")
	}
	return time.UnixMicro(stat.LastAccessTime.Nanoseconds() / 1000), nil
}
